<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="path" value="${pageContext.request.contextPath}" />
#foreach( $field in $fieldList )
#if(${field.inputType}=="select"&&${field.inputValueOne})
<c:set var="${field.field}" value="${${field.field}}" /> 
#end
#end
<html>
<head>
<title>${model.comment}</title>
<%@ include file="/WEB-INF/views/mis/common_inc.jsp"%>
<style>
</style>
</head>

<body style="padding:0 8px;height:100%;overflow:hidden">
<form class="layui-form" action="" id="formSearch">
<blockquote class="layui-elem-quote news_search">

#foreach( $field in $fieldList )
#if(${field.matchType}=="any"||${field.matchType}=="eq"||${field.matchType}=="left"||${field.matchType}=="right")
	<div class="layui-inline">
		    &nbsp;&nbsp;&nbsp;${field.comment}
		    <div class="layui-input-inline">
		    	<input type="text" id="${field.field}" name="${field.field}" placeholder="请输入${field.comment}" class="layui-input search_input">
		    </div>
		</div>
#elseif(${field.matchType}=="select")
#if("$!field.inputValueOne" == "")
	<div class="layui-inline">
		    &nbsp;&nbsp;&nbsp;${field.comment}
		    <div class="layui-input-inline">
				<select id="${field.field}" name="${field.field}" style="display: none;"  lay-search="">
					<option value="">==请选择${field.comment}==</option>
		   			<my:outOptions code="${field.inputValue}" value=""/>
				</select>
		    </div>
	</div>
#else
	<div class="layui-inline">
		    &nbsp;&nbsp;&nbsp;${field.comment}
		    <div class="layui-input-inline">
				<select id="${field.field}" name="${field.field}" style="display: none;" lay-search="">
					<option value="">==请选择${field.comment}==</option>
					<c:forEach items="${${field.inputValueOneL}EntityList}" var="item">
					<option value="${ item.code }">${ item.${field.inputValueTwo}}</option>
					</c:forEach>
				</select>
		    </div>
	</div>
#end
#elseif(${field.matchType}=="numberRange")
		<div class="layui-inline">
		     &nbsp;&nbsp;&nbsp;${field.comment}范围
		    <div class="layui-input-inline">
                <input id="${field.field}_start" name="${field.field}_start" placeholder="开始${field.comment}" autocomplete="off" class="layui-input" type="text">
            </div>
            <div class="layui-input-inline">-</div>
            <div class="layui-input-inline">
                <input id="${field.field}_end" name="${field.field}_end" placeholder="结束${field.comment}" autocomplete="off" class="layui-input" type="text">
            </div>
		</div>
#elseif(${field.matchType}=="dateRange")
		<div class="layui-inline">
		     &nbsp;&nbsp;&nbsp;${field.comment}范围
		    <div class="layui-input-inline">
                <input id="${field.field}_start" name="${field.field}_start" placeholder="开始${field.comment}" autocomplete="off" class="layui-input" type="text">
            </div>
            <div class="layui-input-inline">-</div>
            <div class="layui-input-inline">
                <input id="${field.field}_end" name="${field.field}_end" placeholder="结束${field.comment}" autocomplete="off" class="layui-input" type="text">
            </div>
		</div>
#end
#end
 
		<div class="layui-inline">
			<a id="search_button" class="layui-btn search_btn layui-anim layui-anim-scaleSpring" data-type="reload">查&nbsp;&nbsp;询</a>
		 
			<a class="layui-btn search_btn layui-anim layui-anim-scaleSpring" onClick="doAdd_dg()">新增</a>
		</div>
	</blockquote>
 </form>
<table class="layui-hide" id="LAY_table_user" lay-filter="user"></table> 
       

<script type="text/javascript">
 layui.use(['table','laydate'], function(){
  var table = layui.table;
  var laydate = layui.laydate;
   
#foreach( $field in $fieldList )
#if(${field.matchType}=="dateRange")
	 laydate.render({
		elem: '#${field.field}_start'
	});
	 laydate.render({
		elem: '#${field.field}_end'
	});
#end
#end

     var $ = layui.$, active = {
    reload: function(){
      table.reload('testReload', {
    	  where: { //设定异步数据接口的额外参数，任意设
		 // groupByParm:"",
#foreach( $field in $fieldList )
#if(${field.matchType}=="any"||${field.matchType}=="eq"||${field.matchType}=="left"||${field.matchType}=="right")
			${field.field}: $('#${field.field}').val(),
#elseif(${field.matchType}=="select")
			${field.field}: $('#${field.field}').val(),
#elseif(${field.matchType}=="dateRange"||${field.matchType}=="numberRange")
			${field.field}_start: $('#${field.field}_start').val(),
			${field.field}_end: $('#${field.field}_end').val(),
#end
#end
    	    }
      });
    }
  };
  var formHeight = parseInt(window.document.getElementById('formSearch').offsetHeight)+10;
  //方法级渲染
  var tableIns = table.render({
    elem: '#LAY_table_user'
    ,url: '${path}/${model.modelL}/list'
	,where:{
	//groupByParm:"",
#foreach( $field in $fieldList )
#if(${field.inputType}=="select"&&${field.inputValueOne})
	${field.field}:'${${field.field}}',
#end
#end
	}
    ,cols: [[
	{checkbox:true, fixed: true},//多选
	{field : 'i',title : '序号',width : 60,align : 'center'},
#foreach( $field in $fieldList )
#if($field.listShow == true)
#if(${field.inputType}=="file")
	{field : '${field.columnName}',title : '${field.comment}',width : 140,templet: '#${field.columnName}',align : 'center'},
#elseif(${field.inputType}=="date")
	{field : '${field.columnName}',title : '${field.comment}',width : 140,templet: '#${field.columnName}',align : 'center'},
#elseif(${field.inputType}=="select"||${field.columnName}=='create_code'||${field.columnName}=='update_code')
	{field : '${field.columnName}_name',title : '${field.comment}',width : 140,align : 'center'},
#elseif(${field.inputType}!="hidden")
	{field : '${field.columnName}',title : '${field.comment}',width : 140,align : 'center'},
#end
#end
#end
// {field : 'version',title : '归属',width : 100,templet: '#versionTpl',align : 'center',sort: true},
{field:'action',fixed: 'right',title : '操作',align : 'center',width : 180,templet: '#barDemo'}	
    ]]
    ,id: 'testReload'
    ,page: true
    ,height: 'full-'+formHeight //高度最大化减去差值
  });
  

  
  $('#search_button').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
  
  //监听table事件
  table.on('tool(user)', function(obj){
    var data = obj.data;
    //编辑
    if(obj.event === 'edit'){
    	layer.open({
    		  type: 2,
    		  title: '编辑',
    		  shadeClose: false,
    		  shade: 0.1,
    		  area: ['40%', '60%'],
    		  maxmin: true, //开启最大化最小化按钮
    		  content: '${path}/${model.modelL}/edit?code='+data.code
    		}); 
    }//查看详情
    else if(obj.event === 'show'){
    	layer.open({
    		  type: 2,
    		  title: '详情',
    		  shadeClose: false,
    		  shade: 0.1,
    		  area: ['40%', '60%'],
    		  maxmin: true, //开启最大化最小化按钮
    		  content: '${path}/${model.modelL}/detail?code='+data.code
    		}); 
    }
    //删除
    else if(obj.event === 'del'){
    	layer.confirm('确定删除此数据？',{icon:3, title:'提示信息'},function(){
    			 
    			$.post('${path}/${model.modelL}/delete?code='+data.code,function(data){
    				data=$.parseJSON(data);
    		   		if(data.returnCode=="SUCCESS"){
    		           	//刷新页面
    		           	layer.msg('删除成功');
    		   			$('#search_button').click();
    		        }
    			});
    		});
    }
  });
  $("#formSearch").keydown(function(e){
	   if(e.keyCode==13){
		   $('#search_button').click();
	   }
	});
});
//新增菜单
function doAdd_dg(){
	layer.open({
	  type: 2,
	  title: '新增',
	  shadeClose: false,
	  shade: 0.1,
	  area: ['40%', '60%'],
	  maxmin: true, //开启最大化最小化按钮
	  content: '${path}/${model.modelL}/add'
	}); 
	
}
</script>
#foreach( $field in $fieldList )
#if(${field.inputType}=="file")
<script type="text/html" id="${field.columnName}">
  {{#  if(d.${field.columnName} === ''){ }}
    暂无图片
  {{#  }else{ }}
    <img src="{{ d.${field.columnName} }}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  {{#  } }}
</script>
#elseif(${field.inputType}=="date")
<script type="text/html" id="${field.columnName}">
{{d.${field.columnName}.substring(0,10)}}
</script>
#end
#end
<!-- <script type="text/html" id="versionTpl"> -->
<!--   {{#  if(d.version === 'admin'){ }} -->
<!--     <span>管理平台</span> -->
<!--   {{#  } else if(d.version === 'monitor'){ }} -->
<!--      <span>网点平台</span> -->

<!--   {{#  } }} -->
<!-- </script> -->

<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-mini layui-anim layui-anim-scaleSpring" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-mini layui-anim layui-anim-scaleSpring" lay-event="del">删除</a>
<a class="layui-btn layui-btn-mini layui-anim layui-anim-scaleSpring" lay-event="show">查看</a>
</script>
</body>
</html>